using UnityEngine;

/// <summary>
/// Panel基础脚本
/// </summary>
public class BasePanel : MonoBehaviour
{
    protected virtual void Awake()
    {
        m_selfObj = gameObject;
        m_selfTransform = transform;
    }

    protected virtual void Start()
    {

    }

    protected virtual void Update()
    {
        
    }

    public virtual void Show()
    {
        if (1 == m_state)
            return;

        m_state = 1;
        m_selfObj.SetActive(true);


        OnShow(m_selfTransform);
        RegistEvent();
    }

    protected virtual void RegistEvent()
    {
       
    }


    protected virtual void OnShow(Transform parent)
    {
       
    }

    public virtual void Hide()
    {
        if (0 == m_state)
            return;

        OnHide();
        UnRegistEvent();

        m_selfObj.SetActive(false);
        m_state = 0;
    }

    protected virtual void OnHide()
    {
        
    }

    protected virtual void UnRegistEvent()
    {
       
    }

    /// <summary>
    ///  状态，0：未显示，1：显示
    /// </summary>
    private int m_state = 0;

   
    private GameObject m_selfObj;
    private Transform m_selfTransform;
  
}
